package com.jiayou.game.message

import cn.hutool.core.lang.Console
import cn.hutool.core.util.RandomUtil
import com.jiayou.game.Player

/**
@author 李 双
@data   2020-09-06  11:32
@info
 */

class TicTacToeMessage(var gameHome: String?, var player1: String?, var player2: String?) : Message {

    //    val p1 = player1  //玩家一标识
//    val p2 = player2  //玩家二标识
    var go = if (RandomUtil.randomInt(1, 3) == 1) player1 else player2 //先手

    //三个长度为3的Int数组的二维数组
    var data: Array<IntArray>? = Array(3) { IntArray(3) }

    //赢家
    var winner = ""

    //更新游戏数据
    fun changeData(newData: Array<IntArray>) {
        data = newData
    }

    override fun toString(): String {
//        Console.log(data)
        return "TicTacToeMessage(player1=${player1}, player2=${player2}, data=${data?.contentToString()},go = $go)"
    }


}